package xin.xihc.jba.sql.clause;

import xin.xihc.jba.sql.KV;

/**
 * 条件抽象类
 *
 * @author Leo.Xi
 * @date 2020/3/5
 * @since 1.0
 **/
public abstract class Clause<T> {

    protected String columnName;
    protected T value;

    public Clause(String columnName, T value) {
        this.columnName = columnName;
        this.value = value;
    }

    /**
     * 值
     */
    public abstract T value();

    /**
     * 操作符
     */
    public abstract String operation();

    public String toSql(KV kv) {
        String key = kv.add(this.value());
        return this.columnName + this.operation() + ":" + key;
    }

}
